package com.cxf.windex.rest.admin;

import com.cxf.windex.base.msg.ObjectRestResponse;
import com.cxf.windex.base.rest.BaseRestController;
import com.cxf.windex.biz.BConfigBiz;
import com.cxf.windex.entity.BConfig;
import com.cxf.windex.entity.BShop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: business_needs
 * @description: 广告分成配置
 * @author: chenxf
 * @create: 2018-11-07 09:54
 **/
@Api(tags = {"村广通[后台] - 广告分成管理"})
@Controller
@RequestMapping("admin/config")
public class AdminConfigController extends BaseRestController<BConfigBiz,BConfig> {

  @ApiOperation(value = "获取广告分成配置", notes = "获取广告分成")
  @RequestMapping(value = "/getInfo", method = RequestMethod.GET)
  @ApiImplicitParams({
      @ApiImplicitParam(name = "status", value = "1商户  2后台", required = true, paramType = "query", dataType = "String")
  })
  @ResponseBody
  public ObjectRestResponse getInfo(String status){
    BConfig entity=baseBiz.getInfo(status);
    if(entity==null){
      return new ObjectRestResponse("配置不存在").rel(false);
    }
    return new ObjectRestResponse("查询成功").rel(true).result(entity);
  }

  @ApiOperation(value = "保存配置", notes = "保存配置")
  @RequestMapping(value = "/save", method = RequestMethod.POST)
  @ResponseBody
  public ObjectRestResponse save(BConfig entity){
    baseBiz.save(entity);
    return new ObjectRestResponse("保存成功").rel(true);
  }
}
